class Student():
    def study(self):
        print("我会学习")
class ComputerMajorStudents(Student):
    def study(self):
        super().study()
    def sleep(self):
        print("ComputerMajorStudents我会睡觉")

class StudentsMajoringFinance(Student):
    def study(self):
        super(StudentsMajoringFinance, self).study()
    def sleep(self):
        print("StudentsMajoringFinance我会睡觉")

def fun(self):
    if hasattr(self, "study"):
        print(getattr(self, "study")())
    if hasattr(self, "sleep"):
        print(getattr(self, "sleep")())

student1=Student()
student2=ComputerMajorStudents()
student3=StudentsMajoringFinance()
fun(student1)
fun(student2)
fun(student3)
student2.study()
student2.sleep()
